package o;

import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import java.util.Locale;

public class dom {
    private static final Uri ˊ = Uri.parse("content://telephony/carriers/preferapn/0");
    private static final Uri ˋ = Uri.parse("content://telephony/carriers/preferapn");
    private static final Uri ˎ = Uri.parse("content://telephony/carriers/preferapn/1");

    public static class d {
        private String ˊ;
        private String ˎ;
        private String ˏ;

        public String ˏ() {
            return this.ˏ;
        }

        public void ˎ(String str) {
            this.ˏ = str;
        }

        public String ˋ() {
            return this.ˎ;
        }

        public void ˊ(String str) {
            this.ˎ = str;
        }

        public void ˏ(String str) {
            this.ˊ = str;
        }
    }

    public static d ˊ(Context context) throws SecurityException {
        SecurityException e;
        Cursor cursor;
        Cursor cursor2;
        Exception exception;
        Throwable th;
        d dVar = new d();
        Cursor ˏ;
        try {
            if (don.ॱ()) {
                ˏ = ˏ(context);
            } else {
                ˏ = ˋ(context);
            }
            if (ˏ != null) {
                while (ˏ.moveToNext()) {
                    try {
                        dVar.ˎ(ˏ.getString(ˏ.getColumnIndex("_id")));
                        dVar.ˏ(ˏ.getString(ˏ.getColumnIndex("name")));
                        dVar.ˊ(ˏ.getString(ˏ.getColumnIndex("apn")).toLowerCase(Locale.getDefault()));
                    } catch (SecurityException e2) {
                        e = e2;
                        cursor = ˏ;
                    } catch (Exception e3) {
                        Exception exception2 = e3;
                        cursor2 = ˏ;
                        exception = exception2;
                    } catch (Throwable th2) {
                        th = th2;
                    }
                }
            }
            if (ˏ != null) {
                ˏ.close();
            }
        } catch (SecurityException e4) {
            SecurityException securityException = e4;
            Object obj = null;
            e = securityException;
            try {
                Logger.e("ApnUtil", "getDefaultAPN, SecurityException: " + e.toString());
                throw e;
            } catch (Throwable th3) {
                th = th3;
                ˏ = cursor;
                if (ˏ != null) {
                    ˏ.close();
                }
                throw th;
            }
        } catch (Exception e5) {
            exception = e5;
            cursor2 = null;
            try {
                Logger.e("ApnUtil", "getDefaultAPN, Exception: " + exception.toString());
                if (cursor2 != null) {
                    cursor2.close();
                }
                if (dVar.ˏ() != null) {
                    return dVar;
                }
                return null;
            } catch (Throwable th4) {
                th = th4;
                ˏ = cursor2;
                if (ˏ != null) {
                    ˏ.close();
                }
                throw th;
            }
        } catch (Throwable th5) {
            ˏ = null;
            th = th5;
            if (ˏ != null) {
                ˏ.close();
            }
            throw th;
        }
        if (dVar.ˏ() != null) {
            return null;
        }
        return dVar;
    }

    private static Cursor ˋ(Context context) {
        return context.getContentResolver().query(ˋ, null, null, null, null);
    }

    private static Cursor ˏ(Context context) {
        Cursor ॱॱ;
        if (don.ˋ().ॱ() == 0) {
            ॱॱ = ॱॱ(context);
            if (ॱॱ == null) {
                ॱॱ = ॱ(context);
            }
        } else {
            ॱॱ = ॱ(context);
            if (ॱॱ == null) {
                ॱॱ = ॱॱ(context);
            }
        }
        if (ॱॱ == null) {
            return ˋ(context);
        }
        return ॱॱ;
    }

    private static Cursor ॱ(Context context) {
        return context.getContentResolver().query(ˎ, null, null, null, null);
    }

    private static Cursor ॱॱ(Context context) {
        return context.getContentResolver().query(ˊ, null, null, null, null);
    }

    public static boolean ˎ(Context context) {
        try {
            d ˊ = ˊ(context);
            if (ˊ == null || (ˊ.ˋ() != null && ˊ.ˋ().contains("wap"))) {
                return true;
            }
            return false;
        } catch (SecurityException e) {
            Logger.ˋ("ApnUtil", "isWap(), SecurityException: " + e.toString());
            return false;
        }
    }
}
